package com.example.zsf.activity.mine;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.example.zsf.R;
import com.example.zsf.adapter.AboutListAdapter;
import com.example.zsf.base.ZSFBaseActivity;
import com.example.zsf.model.ItemDataModel;
import com.example.zsf.utils.DebouncedOnItemClickListener;
import com.example.zsf.view.NavigationBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AboutActivity extends ZSFBaseActivity {

    @BindView(R.id.navigation_bar)
    NavigationBar navigationBar;
    @BindView(R.id.version_tv)
    TextView versionTv;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    private AboutListAdapter aboutListAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_about);
        ButterKnife.bind(this);
        initUI();
    }

    private void initUI() {
        Window window = getWindow();
        View decorView = window.getDecorView();
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
        }


        navigationBar.setLeftClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });


        List<ItemDataModel> itemDataModels = new ArrayList<>();
        ItemDataModel itemDataModel = new ItemDataModel();
        itemDataModel.type = 0;
        itemDataModel.title = "版本介绍";
        ItemDataModel itemDataModel1 = new ItemDataModel();
        itemDataModel1.type = 1;
        itemDataModel1.title = "检查更新";
        ItemDataModel itemDataModel2 = new ItemDataModel();
        itemDataModel2.type = 2;
        itemDataModel2.title = "意见反馈";
        itemDataModels.add(itemDataModel);
        itemDataModels.add(itemDataModel1);
        itemDataModels.add(itemDataModel2);

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        aboutListAdapter = new AboutListAdapter(R.layout.item_about, itemDataModels);

        aboutListAdapter.setOnItemClickListener(new DebouncedOnItemClickListener(400) {
            @Override
            public void onDebouncedItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                ItemDataModel item = (ItemDataModel) adapter.getItem(position);
                switch (item.type) {
                    case 0:
                        break;
                    case 1:
                        break;
                    case 2: {
                        Intent intent = new Intent(AboutActivity.this, ContactActivity.class);
                        startActivity(intent);
                    }
                    break;
                    default:
                        break;
                }
            }
        });
        recyclerView.setAdapter(aboutListAdapter);
    }
}